package com.foreknow.demo02;


import java.util.Scanner;

public class HomeWork3 {
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        //设置初始值
        int num = 0;
        String password = "";
        String password1="";
        String password2 ="";
        String name ="";
        String name1 = "";
        String name2 = "";
        int time = 3;
        boolean isRight= false;
        boolean aa = false;
        do{
            System.out.println("**********进入系统*********");
            System.out.println("1.注册");
            System.out.println("2.登录");
            System.out.println("3.抽奖");
            System.out.println("**************************");
            System.out.println("请选择菜单：");

            //接受控制台的输入
            int choose = input.nextInt();
            isRight = true;


            switch(choose){
                case 1 :
                    System.out.println("[注册]");
                    System.out.println("请填写个人注册信息");
                    System.out.println("用户名：");
                    name = input.next();
                    System.out.println("密码：");
                    password = input.next();
                    num = (int)(Math.random()*(9999-1000))+1000;
                    System.out.println("注册成功");
                    System.out.println("请记住您的会员号："+num);
                    System.out.println("用户名："+name);
                    System.out.println("密码："+password);
                    break;

                case 2 :
                    do {
                        aa= true;
                        System.out.println("[登录]");
                        System.out.println("请输入用户名：");
                        name1 = input.next();
                        System.out.println("请输入密码：");
                        password1 = input.next();

                        //判断密码是否正确
                        if(name1.equals(name) && password.equals(password1)){
                            System.out.println("输入正确，成功登录");
                        }else{
                            System.out.println("输入错误请重新输入");
                            time--;
                            System.out.println("您还剩余"+time+"次机会");
                            if(time == 0){
                                System.out.println("次数用尽");
                                break;
                            }
                            aa = false;
                        }
                    }while(!aa);
                    break;

                case 3 :
                    System.out.println("[抽奖]");
                    break;
            }

            System.out.println("是否继续：（y/n）");
            String select = input.next();
            if(select.equals("y")){
                isRight = false;
            }else{
                isRight = true;
            }
        }while(!isRight);
        System.out.println("退出系统");


    }
}
